{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from pyecharts import Boxplot\n",
    "from pyecharts import Bar \n",
    "from pyecharts import Pie\n",
    "from pyecharts import Scatter\n",
    "from pyecharts import WordCloud\n",
    "import numpy as np\n",
    "from snownlp import SnowNLP\n",
    "import jieba\n",
    "# from wordcloud import WordCloud,STOPWORDS,ImageColorGenerator\n",
    "from matplotlib import pyplot as plt\n",
    "import os\n",
    "import collections\n",
    "import seaborn as sns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# title = '厨房用品、厨房电器'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "导出数据共有318859行，8列！\n",
      "读取数据源成功！！\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"5948091d3a4f4dbca1b328e48da86b23\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_5948091d3a4f4dbca1b328e48da86b23 = echarts.init(document.getElementById('5948091d3a4f4dbca1b328e48da86b23'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_5948091d3a4f4dbca1b328e48da86b23 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6309\\u5927\\u7c7b\\u7bb1\\u7ebf\\u56fe\\u68c0\\u6d4b\\u5f02\\u5e38\\u503c\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 6468761,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"boxplot\",\n",
       "            \"name\": \"\\u5927\\u7c7b\",\n",
       "            \"data\": [\n",
       "                [\n",
       "                    9.9,\n",
       "                    95.5,\n",
       "                    185.0,\n",
       "                    536.25,\n",
       "                    39500.0\n",
       "                ],\n",
       "                [\n",
       "                    2.0,\n",
       "                    95.25,\n",
       "                    205.5,\n",
       "                    398.75,\n",
       "                    3690.0\n",
       "                ],\n",
       "                [\n",
       "                    25.8,\n",
       "                    218.0,\n",
       "                    688.0,\n",
       "                    2199.0,\n",
       "                    98888.0\n",
       "                ],\n",
       "                [\n",
       "                    14.0,\n",
       "                    272.5,\n",
       "                    700.0,\n",
       "                    1899.5,\n",
       "                    18800.0\n",
       "                ],\n",
       "                [\n",
       "                    24.9,\n",
       "                    199.0,\n",
       "                    699.0,\n",
       "                    2199.0,\n",
       "                    10999.0\n",
       "                ],\n",
       "                [\n",
       "                    79.0,\n",
       "                    353.5,\n",
       "                    999.0,\n",
       "                    5144.0,\n",
       "                    399900.0\n",
       "                ],\n",
       "                [\n",
       "                    9.0,\n",
       "                    302.0,\n",
       "                    1293.0,\n",
       "                    4098.75,\n",
       "                    500000.0\n",
       "                ],\n",
       "                [\n",
       "                    12.9,\n",
       "                    68.75,\n",
       "                    175.5,\n",
       "                    379.25,\n",
       "                    6414.0\n",
       "                ],\n",
       "                [\n",
       "                    58.0,\n",
       "                    461.25,\n",
       "                    1125.0,\n",
       "                    4474.5,\n",
       "                    198000.0\n",
       "                ],\n",
       "                [\n",
       "                    19.8,\n",
       "                    243.5,\n",
       "                    534.0,\n",
       "                    1090.75,\n",
       "                    11800.0\n",
       "                ],\n",
       "                [\n",
       "                    99.0,\n",
       "                    1153.5,\n",
       "                    3398.0,\n",
       "                    6049.0,\n",
       "                    32999.0\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 6468761\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5927\\u7c7b\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 45,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u6bcd\\u5a74\\u3001\\u73a9\\u5177\\u3001\\u5ba0\\u7269\",\n",
       "                \"\\u5316\\u5986\\u54c1\\u3001\\u6d17\\u62a4\\u6c90\\u6d74\",\n",
       "                \"\\u53a8\\u623f\\u7528\\u54c1\\u3001\\u53a8\\u623f\\u7535\\u5668\",\n",
       "                \"\\u4fdd\\u5065\\u54c1\\u3001\\u8fd0\\u52a8\\u6237\\u5916\\u3001\\u5668\\u68b0\",\n",
       "                \"\\u624b\\u673a\\u3001\\u6570\\u7801\\u3001\\u7535\\u8111\",\n",
       "                \"\\u6c7d\\u8f66\\u3001\\u65c5\\u6e38\\u3001\\u4fdd\\u9669\\u3001\\u670d\\u52a1\",\n",
       "                \"\\u5bb6\\u5c45\\u3001\\u5bb6\\u9970\",\n",
       "                \"\\u98df\\u54c1\\u996e\\u6599\",\n",
       "                \"\\u73e0\\u5b9d\\u3001\\u6536\\u85cf\\u3001\\u949f\\u8868\",\n",
       "                \"\\u670d\\u88c5\\u3001\\u978b\\u9774\\u3001\\u7bb1\\u5305\\u3001\\u914d\\u9970\",\n",
       "                \"\\u5bb6\\u7528\\u7535\\u5668\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_5948091d3a4f4dbca1b328e48da86b23.setOption(option_5948091d3a4f4dbca1b328e48da86b23);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.boxplot.Boxplot at 0x4976a58>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 载入数据\n",
    "data = pd.read_csv('./data_list/data_list_after_groupby.csv', sep=',', header=0, encoding='utf-8',engine='python',dtype=str)\n",
    "# data = data.iloc[:10001, :]\n",
    "# data = data[data['title'] == title]\n",
    "print('导出数据共有{}行，{}列！'.format(data.shape[0], data.shape[1]))\n",
    "print('读取数据源成功！！')   \n",
    "    \n",
    "# 按大类箱线图检测异常值  ——  pyecharts\n",
    "title_name = data['title'].unique()\n",
    "title_name = list(title_name)\n",
    "title_price = []\n",
    "for title in title_name:\n",
    "    pro_price = data[data['title']==title]['pro_price'].astype(float).unique()\n",
    "    pro_price = list(pro_price)\n",
    "    title_price.append(pro_price)\n",
    "# print(f'title_price是 {np.array(title_price).shape[0]}维数据')\n",
    "title_price\n",
    "boxplot = Boxplot('按大类箱线图检测异常值')\n",
    "x_axis = title_name\n",
    "y_axis = title_price\n",
    "_yaxis = boxplot.prepare_data(y_axis)\n",
    "boxplot.add('大类', x_axis, _yaxis,xaxis_rotate=45,width=1600,height=800)\n",
    "boxplot.render('./data_list/boxplot_all_output.html')\n",
    "boxplot\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"a88d9b1cb9394ff2a5217c38792446b4\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_a88d9b1cb9394ff2a5217c38792446b4 = echarts.init(document.getElementById('a88d9b1cb9394ff2a5217c38792446b4'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_a88d9b1cb9394ff2a5217c38792446b4 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8bc4\\u5206\\u533a\\u95f4\\u76f4\\u65b9\\u56fe \",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 6448952,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u8bc4\\u5206\\u533a\\u95f4\",\n",
       "            \"data\": [\n",
       "                32311,\n",
       "                12448,\n",
       "                10930,\n",
       "                10769,\n",
       "                11508,\n",
       "                13578,\n",
       "                15993,\n",
       "                21241,\n",
       "                34482,\n",
       "                155598,\n",
       "                1\n",
       "            ],\n",
       "            \"barCategoryGap\": 0,\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 6448952\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8bc4\\u5206\\u533a\\u95f4\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"0\",\n",
       "                \"0.1\",\n",
       "                \"0.2\",\n",
       "                \"0.3\",\n",
       "                \"0.4\",\n",
       "                \"0.5\",\n",
       "                \"0.6\",\n",
       "                \"0.7\",\n",
       "                \"0.8\",\n",
       "                \"0.9\",\n",
       "                \"1.0\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_a88d9b1cb9394ff2a5217c38792446b4.setOption(option_a88d9b1cb9394ff2a5217c38792446b4);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x2d7beef0>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 单变量：评分区间直方图  ——  pyecharts\n",
    "sentiment_score = data['sentiment_score'].astype(float)\n",
    "group = [0, 0.1, 0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1]\n",
    "data['group_num'] = pd.cut(sentiment_score, group, labels=['0', '0.1', '0.2', '0.3','0.4','0.5','0.6','0.7','0.8','0.9','1.0'],right=False)\n",
    "data_hist = pd.pivot_table(data,index=['group_num'],values=['sentiment_score'],aggfunc=[len])\n",
    "data_hist.reset_index(inplace=True)\n",
    "data_hist.sort_values(by='group_num',ascending=True,inplace=True)\n",
    "x_axis_list = list(data_hist['group_num'])\n",
    "y_axis_list = list(data_hist[('len','sentiment_score')])\n",
    "# print(x_axis_list,y_axis_list)\n",
    "bar = Bar('评分区间直方图 ')\n",
    "x_axis = x_axis_list\n",
    "y_axis = y_axis_list\n",
    "bar.add('评分区间', x_axis, y_axis,bar_category_gap=0,is_label_show=True)\n",
    "bar.render('./data_list/hist_all_output.html')\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1    好评\n",
      "2    差评\n",
      "0    中评\n",
      "Name: group, dtype: object 1    219790\n",
      "2     61017\n",
      "0     38051\n",
      "Name: (len, item_id), dtype: int64\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"9e24f61dd0c44925a5056153e96df234\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_9e24f61dd0c44925a5056153e96df234 = echarts.init(document.getElementById('9e24f61dd0c44925a5056153e96df234'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_9e24f61dd0c44925a5056153e96df234 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8bc4\\u8bba\\u5206\\u7c7b\\u997c\\u56fe\",\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 3105126,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u597d\\u8bc4\",\n",
       "                    \"value\": 219790\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5dee\\u8bc4\",\n",
       "                    \"value\": 61017\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e2d\\u8bc4\",\n",
       "                    \"value\": 38051\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"40%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"outside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                }\n",
       "            },\n",
       "            \"seriesId\": 3105126\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u597d\\u8bc4\",\n",
       "                \"\\u5dee\\u8bc4\",\n",
       "                \"\\u4e2d\\u8bc4\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"left\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_9e24f61dd0c44925a5056153e96df234.setOption(option_9e24f61dd0c44925a5056153e96df234);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.pie.Pie at 0x2d7beda0>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 单变量：评论分类饼图  ——  pyecharts\n",
    "pie_data = pd.pivot_table(data,index=['group'],values=['item_id'],aggfunc=[len])\n",
    "pie_data.reset_index(inplace=True)\n",
    "pie_data.sort_values(by=('len','item_id'),ascending=False,inplace=True)\n",
    "size = pie_data[('len','item_id')]\n",
    "labels = pie_data['group']\n",
    "print(labels,size)\n",
    "pie = Pie('评论分类饼图', title_pos='center')\n",
    "attr = list(labels)\n",
    "v1 = list(size)\n",
    "pie.add('', attr, v1,radius=[40, 75],label_text_color=None,is_label_show=True,legend_orient='vertical',legend_pos='left')\n",
    "pie.render('./data_list/pie_all_output.html')\n",
    "pie"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"639b56b3b97b4086888f66cc5240ad9b\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_639b56b3b97b4086888f66cc5240ad9b = echarts.init(document.getElementById('639b56b3b97b4086888f66cc5240ad9b'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_639b56b3b97b4086888f66cc5240ad9b = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5927\\u7c7b\\u6761\\u5f62\\u56fe \",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 8717386,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u8bc4\\u8bba\\u6570\",\n",
       "            \"data\": [\n",
       "                761,\n",
       "                1276,\n",
       "                1584,\n",
       "                12553,\n",
       "                16335,\n",
       "                24203,\n",
       "                34080,\n",
       "                34120,\n",
       "                51545,\n",
       "                62805,\n",
       "                79597\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"right\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 8717386\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8bc4\\u8bba\\u6570\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u624b\\u673a\\u3001\\u6570\\u7801\\u3001\\u7535\\u8111\",\n",
       "                \"\\u6c7d\\u8f66\\u3001\\u65c5\\u6e38\\u3001\\u4fdd\\u9669\\u3001\\u670d\\u52a1\",\n",
       "                \"\\u6bcd\\u5a74\\u3001\\u73a9\\u5177\\u3001\\u5ba0\\u7269\",\n",
       "                \"\\u73e0\\u5b9d\\u3001\\u6536\\u85cf\\u3001\\u949f\\u8868\",\n",
       "                \"\\u5bb6\\u7528\\u7535\\u5668\",\n",
       "                \"\\u53a8\\u623f\\u7528\\u54c1\\u3001\\u53a8\\u623f\\u7535\\u5668\",\n",
       "                \"\\u5316\\u5986\\u54c1\\u3001\\u6d17\\u62a4\\u6c90\\u6d74\",\n",
       "                \"\\u4fdd\\u5065\\u54c1\\u3001\\u8fd0\\u52a8\\u6237\\u5916\\u3001\\u5668\\u68b0\",\n",
       "                \"\\u5bb6\\u5c45\\u3001\\u5bb6\\u9970\",\n",
       "                \"\\u670d\\u88c5\\u3001\\u978b\\u9774\\u3001\\u7bb1\\u5305\\u3001\\u914d\\u9970\",\n",
       "                \"\\u98df\\u54c1\\u996e\\u6599\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_639b56b3b97b4086888f66cc5240ad9b.setOption(option_639b56b3b97b4086888f66cc5240ad9b);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x2d7bed68>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 单变量：大类条形图  ——  pyecharts\n",
    "hbar_data = pd.pivot_table(data,index=['title'],values=['item_id'],aggfunc=[len])\n",
    "hbar_data.reset_index(inplace=True)\n",
    "hbar_data.sort_values(by=('len','item_id'),ascending=True,inplace=True)\n",
    "title_name = hbar_data['title']\n",
    "size = hbar_data[('len','item_id')]\n",
    "x_axis_list = list(title_name)\n",
    "y_axis_list = list(size)\n",
    "bar = Bar('大类条形图 ')\n",
    "x_axis = x_axis_list\n",
    "y_axis = y_axis_list\n",
    "bar.add('评论数', x_axis, y_axis,is_convert=True,is_label_show=True,label_pos='right')\n",
    "bar.render('./data_list/hbar_all_output.html')\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"660e78dfa46a454fa1e31bbca7f76cb7\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_660e78dfa46a454fa1e31bbca7f76cb7 = echarts.init(document.getElementById('660e78dfa46a454fa1e31bbca7f76cb7'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_660e78dfa46a454fa1e31bbca7f76cb7 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5927\\u7c7b\\u8bc4\\u8bba\\u5206\\u6570\\u67f1\\u72b6\\u56fe \",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 3442395,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u8bc4\\u8bba\\u5206\\u6570\",\n",
       "            \"data\": [\n",
       "                \"0.78\",\n",
       "                \"0.77\",\n",
       "                \"0.77\",\n",
       "                \"0.77\",\n",
       "                \"0.74\",\n",
       "                \"0.73\",\n",
       "                \"0.71\",\n",
       "                \"0.69\",\n",
       "                \"0.67\",\n",
       "                \"0.64\",\n",
       "                \"0.63\"\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 3442395\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8bc4\\u8bba\\u5206\\u6570\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 45,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u73e0\\u5b9d\\u3001\\u6536\\u85cf\\u3001\\u949f\\u8868\",\n",
       "                \"\\u624b\\u673a\\u3001\\u6570\\u7801\\u3001\\u7535\\u8111\",\n",
       "                \"\\u670d\\u88c5\\u3001\\u978b\\u9774\\u3001\\u7bb1\\u5305\\u3001\\u914d\\u9970\",\n",
       "                \"\\u4fdd\\u5065\\u54c1\\u3001\\u8fd0\\u52a8\\u6237\\u5916\\u3001\\u5668\\u68b0\",\n",
       "                \"\\u6bcd\\u5a74\\u3001\\u73a9\\u5177\\u3001\\u5ba0\\u7269\",\n",
       "                \"\\u5316\\u5986\\u54c1\\u3001\\u6d17\\u62a4\\u6c90\\u6d74\",\n",
       "                \"\\u98df\\u54c1\\u996e\\u6599\",\n",
       "                \"\\u53a8\\u623f\\u7528\\u54c1\\u3001\\u53a8\\u623f\\u7535\\u5668\",\n",
       "                \"\\u5bb6\\u5c45\\u3001\\u5bb6\\u9970\",\n",
       "                \"\\u6c7d\\u8f66\\u3001\\u65c5\\u6e38\\u3001\\u4fdd\\u9669\\u3001\\u670d\\u52a1\",\n",
       "                \"\\u5bb6\\u7528\\u7535\\u5668\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_660e78dfa46a454fa1e31bbca7f76cb7.setOption(option_660e78dfa46a454fa1e31bbca7f76cb7);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x2d7eea20>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 双变量：大类、评论分数柱状图  ——  pyecharts\n",
    "data['sentiment_score'] = data['sentiment_score'].astype(float)\n",
    "bar_data = pd.pivot_table(data,index=['title'],values=['sentiment_score'],aggfunc=[np.mean])\n",
    "bar_data.reset_index(inplace=True)\n",
    "bar_data.sort_values(by=('mean','sentiment_score'),ascending=False,inplace=True)\n",
    "f = lambda x: '%.2f'%x\n",
    "bar_data[('mean','sentiment_score')] = bar_data[('mean','sentiment_score')].map(f)\n",
    "title_name = bar_data['title']\n",
    "score = bar_data[('mean','sentiment_score')]\n",
    "x_axis_list = list(title_name)\n",
    "y_axis_list = list(score)\n",
    "bar = Bar('大类评论分数柱状图 ')\n",
    "x_axis = x_axis_list\n",
    "y_axis = y_axis_list\n",
    "bar.add('评论分数', x_axis, y_axis,xaxis_rotate=45,is_label_show=True)\n",
    "bar.render('./data_list/bar_all_output.html')\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 双变量：价格、评论分数散点图  ——  pyecharts\n",
    "# sentiment_score = data['sentiment_score'].astype(float)\n",
    "# pro_price = data['pro_price'].astype(float)\n",
    "# x_axis_list = list(sentiment_score)\n",
    "# y_axis_list = list(pro_price)\n",
    "# x_axis = x_axis_list\n",
    "# y_axis = y_axis_list\n",
    "# scatter = Scatter('价格评论分数散点图')\n",
    "# scatter.add('', x_axis, y_axis, symbol_size=5,is_visualmap=True)\n",
    "# scatter.render('./data_list/scatter_all_output.html')\n",
    "# scatter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Building prefix dict from the default dictionary ...\n",
      "DEBUG:jieba:Building prefix dict from the default dictionary ...\n",
      "Loading model from cache C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\jieba.cache\n",
      "DEBUG:jieba:Loading model from cache C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\jieba.cache\n",
      "Loading model cost 0.921 seconds.\n",
      "DEBUG:jieba:Loading model cost 0.921 seconds.\n",
      "Prefix dict has been built succesfully.\n",
      "DEBUG:jieba:Prefix dict has been built succesfully.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min', 'wordcloud': '/nbextensions/echarts/echarts-wordcloud.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"0bd7ce1488ab48e3a20d4ce42160c6cc\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts', 'wordcloud'], function(echarts) {\n",
       "        \n",
       "var myChart_0bd7ce1488ab48e3a20d4ce42160c6cc = echarts.init(document.getElementById('0bd7ce1488ab48e3a20d4ce42160c6cc'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_0bd7ce1488ab48e3a20d4ce42160c6cc = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 3189435,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"wordCloud\",\n",
       "            \"name\": \"\\u8bc4\\u8bba\\u8bcd\\u4e91\\u56fe\",\n",
       "            \"shape\": \"diamond\",\n",
       "            \"rotationRange\": [\n",
       "                0,\n",
       "                0\n",
       "            ],\n",
       "            \"rotationStep\": 45,\n",
       "            \"girdSize\": 20,\n",
       "            \"sizeRange\": [\n",
       "                10,\n",
       "                100\n",
       "            ],\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u559c\\u6b22\",\n",
       "                    \"value\": 37223,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(150,14,56)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6ee1\\u610f\",\n",
       "                    \"value\": 30384,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(24,83,87)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8d28\\u91cf\",\n",
       "                    \"value\": 28754,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(132,156,44)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4ef7\\u683c\",\n",
       "                    \"value\": 26013,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(1,123,127)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8212\\u670d\",\n",
       "                    \"value\": 20954,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(22,100,29)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5473\\u9053\",\n",
       "                    \"value\": 17813,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(147,135,33)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b9e\\u60e0\",\n",
       "                    \"value\": 15083,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(113,142,159)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6548\\u679c\",\n",
       "                    \"value\": 15044,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(21,93,94)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u597d\\u5403\",\n",
       "                    \"value\": 14166,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(92,104,58)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5f88\\u5feb\",\n",
       "                    \"value\": 13849,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(133,38,3)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9001\\u8d27\",\n",
       "                    \"value\": 13719,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(113,120,106)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u503c\\u5f97\",\n",
       "                    \"value\": 12880,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(14,30,22)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u989c\\u8272\",\n",
       "                    \"value\": 12600,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(80,70,49)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5feb\\u9012\",\n",
       "                    \"value\": 11676,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(12,27,132)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7a7f\\u7740\",\n",
       "                    \"value\": 11189,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(135,41,63)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7269\\u6d41\",\n",
       "                    \"value\": 11122,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(112,32,114)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5305\\u88c5\",\n",
       "                    \"value\": 10913,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(36,36,59)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u54c1\\u724c\",\n",
       "                    \"value\": 10295,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(53,137,62)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u901f\\u5ea6\",\n",
       "                    \"value\": 9538,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(6,44,80)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u914d\\u9001\",\n",
       "                    \"value\": 9290,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(118,56,46)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8863\\u670d\",\n",
       "                    \"value\": 8830,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(137,81,159)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u653e\\u5fc3\",\n",
       "                    \"value\": 8471,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(123,58,65)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u724c\\u5b50\",\n",
       "                    \"value\": 8032,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(68,124,12)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u597d\\u770b\",\n",
       "                    \"value\": 8028,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(157,23,42)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4fbf\\u5b9c\",\n",
       "                    \"value\": 7925,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(130,23,45)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6027\\u4ef7\\u6bd4\",\n",
       "                    \"value\": 7292,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(25,14,38)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u670d\\u52a1\",\n",
       "                    \"value\": 6920,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(144,84,103)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b89\\u88c5\",\n",
       "                    \"value\": 6730,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(106,110,128)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4fe1\\u8d56\",\n",
       "                    \"value\": 6291,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(96,121,34)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u53e3\\u611f\",\n",
       "                    \"value\": 6120,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(114,22,122)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u670b\\u53cb\",\n",
       "                    \"value\": 6071,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(39,158,19)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4f18\\u60e0\",\n",
       "                    \"value\": 5989,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(157,19,39)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u63a8\\u8350\",\n",
       "                    \"value\": 5845,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(109,78,93)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8212\\u9002\",\n",
       "                    \"value\": 5754,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(52,81,32)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u54c1\\u8d28\",\n",
       "                    \"value\": 5528,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(112,125,152)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65b0\\u9c9c\",\n",
       "                    \"value\": 5505,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(95,104,147)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d3b\\u52a8\",\n",
       "                    \"value\": 5467,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(76,154,67)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u67d4\\u8f6f\",\n",
       "                    \"value\": 5298,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(16,88,98)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9762\\u6599\",\n",
       "                    \"value\": 5145,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(114,14,31)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9002\\u5408\",\n",
       "                    \"value\": 5002,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(24,126,5)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5927\\u5c0f\",\n",
       "                    \"value\": 4841,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(59,106,104)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5408\\u9002\",\n",
       "                    \"value\": 4812,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(125,153,150)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5212\\u7b97\",\n",
       "                    \"value\": 4787,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(109,92,65)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e70\\u8fc7\",\n",
       "                    \"value\": 4671,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(119,105,93)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e72\\u51c0\",\n",
       "                    \"value\": 4540,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(132,75,147)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u505a\\u5de5\",\n",
       "                    \"value\": 4469,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(48,153,44)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6b3e\\u5f0f\",\n",
       "                    \"value\": 4466,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(125,90,44)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6f02\\u4eae\",\n",
       "                    \"value\": 4457,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(2,30,127)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u670d\\u52a1\\u6001\\u5ea6\",\n",
       "                    \"value\": 4247,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(59,86,83)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u597d\\u7528\",\n",
       "                    \"value\": 4223,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(127,150,21)\"\n",
       "                        }\n",
       "                    }\n",
       "                }\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_0bd7ce1488ab48e3a20d4ce42160c6cc.setOption(option_0bd7ce1488ab48e3a20d4ce42160c6cc);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.wordcloud.WordCloud at 0x2d7fbd68>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 词云  ——  pyecharts \n",
    "data_cut_words = pd.DataFrame(data.astype(str))\n",
    "# data_cut_words['cut_comment'] = data_duplicate_words['seg_comment'].apply(cut_words)\n",
    "# stopwords = load_stopwords()\n",
    "stopwords = [line.strip() for line in open('./常见中文停用词表.txt', encoding='gbk').readlines()]\n",
    "# 保存全局分词，用于词频统计\n",
    "segments = []\n",
    "# 普通分词及停用词判断\n",
    "for index, row in data_cut_words.iterrows():\n",
    "    content = row[5]\n",
    "    # TextRank 关键词抽取，只获取固定词性\n",
    "    words = jieba.cut(content,cut_all=False)\n",
    "    # splitedStr = ''\n",
    "    for word in words:\n",
    "        # 停用词判断，如果当前的关键词不在停用词库中才进行记录\n",
    "        if word not in stopwords:\n",
    "            # 记录全局分词\n",
    "            segments.append(word)\n",
    "            # splitedStr += word + ' '\n",
    "word_counts = collections.Counter(segments) # 对分词做词频统计\n",
    "word_counts_top10 = word_counts.most_common(50) # 获取前50最高频的词\n",
    "# print ('文本词频最高的前50个词是: {}'.format(word_counts_top10)) # 输出检查\n",
    "# 设置中文字体\n",
    "# font_path = os.path.join('C:\\Windows\\Fonts', 'FZYTK.TTF')\n",
    "# 生成词云\n",
    "# wc = WordCloud(font_path=font_path, margin=2, scale=10, max_words=200, min_font_size=4,random_state=42, background_color='white', max_font_size=150)\n",
    "# wc.generate_from_frequencies(word_counts)\n",
    "# 获取文本词排序，可调整 stopwords\n",
    "# process_word = WordCloud.process_text(wc, text)\n",
    "# sort = sorted(process_word.items(), key=lambda e: e[1], reverse=True)\n",
    "# 获取文本词频最高的前50个词\n",
    "# print('文本词频最高的前50个词是: {}'.format(sort[:50]))\n",
    "\n",
    "words = []\n",
    "counts = []\n",
    "\n",
    "for item in word_counts_top10:\n",
    "    word = item[0]\n",
    "    count = item[1]\n",
    "    words.append(word)\n",
    "    counts.append(count)\n",
    "    \n",
    "attr = words\n",
    "value = counts\n",
    "wordcloud = WordCloud(width=800, height=400)\n",
    "wordcloud.add('评论词云图', attr, value,word_size_range=[10, 100],shape='diamond')\n",
    "wordcloud.render('./data_list/wordcloud_all_output.html')\n",
    "wordcloud"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
